% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fixnames_aliases.R
\name{fixnames_aliases}
\alias{fixnames_aliases}
\title{Convert terms to standardized terms based on synonyms}
\usage{
fixnames_aliases(
  x,
  na_if_no_match = FALSE,
  alias_list = NULL,
  ignore.case = TRUE
)
}
\arguments{
\item{x}{vector of terms, such as colnames(testpoints_10), etc.}

\item{na_if_no_match}{optional, set to TRUE if you want it to return NA
for each element of x not found in the alias_list info}

\item{alias_list}{built-in already in source code (but can replace
using this optional parameter), a list of named vectors where
names are standard, preferred, canonical versions of terms, and
each vector is a set of aliases for that term.}

\item{ignore.case}{optional set to FALSE if you want to not ignore case}
}
\value{
character vector like x but where some or all may be replaced by
standardized versions of the elements of x, or NA if appropriate
}
\description{
Convert terms to standardized terms based on synonyms
}
\details{
\code{\link[=fixcolnames_infer]{fixcolnames_infer()}} and \code{\link[=fixnames_aliases]{fixnames_aliases()}} are very similar.
\itemize{
\item \code{\link[=fixcolnames_infer]{fixcolnames_infer()}} is designed to figure out for a data.frame
which one column is the best guess (top pick) for which should be
used as the "lat" column, for example,
so when several colnames are matches based on the alias_list,
this function picks only one of them to rename to the preferred or
canonical name, leaving others as-is.
\item In contrast to that, \code{\link[=fixnames_aliases]{fixnames_aliases()}} is more general and
every input element that can be matched with a
canonical name gets changed to that preferred version, so
even if multiple input names are different aliases of "lat",
for example, they all get changed to "lat."
}

The alias_list could be for example this:

\preformatted{
 alias_list <- list(
  sqkm = c('km2', 'kilometer2','kilometers2', 'sq kilometers', 'sq kilometer',
   'sqkilometers', 'sqkilometer',  'squarekilometers', 'squarekilometer',
   'square kilometers', 'square kilometer'),
  sqm = c('m2', 'meter2','meters2', 'sq meters', 'sq meter','sqmeters', 'sqmeter',
  'squaremeters', 'squaremeter', 'square meters', 'square meter'),
  mi = c('mile', 'miles'),
  
  lat = lat_alias,
  #[1]"lat" "latitude83" "latitude" "latitudes"  "faclat" "lats" "y" 
  lon = lon_alias, 
  #[1]"lon" "longitude83" "longitude" "longitudes" "faclong" "lons" "long" "longs" "lng" "x"
  
)
}
}
\examples{
fixnames_aliases(c("km", "kilometer", "miles", "statename", 'X', "y"))
fixnames_aliases("LATITUDE")
fixnames_aliases("LATITUDE", ignore.case = F)
fixnames_aliases("LATITUDE", na_if_no_match = T)
fixnames_aliases("LATITUDE", na_if_no_match = T, ignore.case = F)
fixnames_aliases(c(NA, 1, "typo", 1:2, list()))

fixnames_aliases(c(1:4, "na", "tbd"), 
  alias_list = list(upto1 = 0:1, company = 2, crowd = 3:10, other = c("na", "tbd")))

}
\seealso{
\code{\link[=fixcolnames_infer]{fixcolnames_infer()}} \code{\link[=latlon_infer]{latlon_infer()}}
}
